<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Course extends Model
{
    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'company_course';
    use HasFactory;

    public function videos()
    {
        return $this->hasMany('App\Models\CourseVideo','course_uniqid','uniqid')->select('id','title','duration','course_uniqid','sort');
    }

    public function studyVideos()
    {
        return $this->hasMany('App\Models\CourseVideo','course_uniqid','uniqid')->select('id','title','duration','course_uniqid','sort','play_url','file_id','is_off');
    }

    public function comments()
    {
        return $this->hasMany('App\Models\Reviews','product_id','id')->where('status',1)->with('user');
    }

    public function org()
    {
        return $this->hasOne('App\Models\Enterprise','id','eid')->select('id','name','full_name','tell');
    }

    public function types()
    {
        return $this->hasOne('App\Models\ProColumn','id','top_category')->select('id','title');
    }

    public function two_types()
    {
        return $this->hasOne('App\Models\ProColumn','id','secondary_category')->select('id','title');
    }

    public function class()
    {
        return $this->belongsToMany('App\Models\ProColumn','course_class','class_id','course_id');
    }

    
}
